package com.sensePlusVR.utils;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

import java.util.ArrayList;
import java.util.List;

public class PackageUtils {

    /**
     * 获取所有的app包名
     * @param context
     * @return
     */
    public static ArrayList<String> getAppPackageName(Context context) {
        PackageManager packageManager = context.getPackageManager();
        ArrayList<String> resArrayList = new ArrayList<String>();
        List<PackageInfo> list = packageManager
                .getInstalledPackages(PackageManager.GET_PERMISSIONS);
        for (PackageInfo packageInfo : list) {
            ApplicationInfo applicationInfo = packageInfo.applicationInfo;
            resArrayList.add(applicationInfo.packageName);
            
        }
        return resArrayList;
    }
}
